<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            width: 300px;
            height: 350px;
            background-color: aliceblue;
            border-radius: 10px;
            margin: 100px auto;
            padding: 40px 20px;
        }

        .zi {
            font-size: 20px;
            font-weight: bold;
        }
        .zheng input{
            height: 30px;
            border: 0;
            border-bottom: 1px solid #eee;
            margin: 10px 0;
            width: 230px;
            border-radius: 15px;
            padding: 0 10px;
        }
     .c1{
        margin-left: 10px;
        color: blue;
     }
       .hang span{
        font-weight: bold;
       }
       .nei{
        display: inline-block;
        height: 30px;
        padding: 0 10px;
        background-color: #eeee;
        border-radius: 5px;
        line-height: 30px;
        margin-top: 10px;
       }
    </style>
</head>

<body>
    <div class="box">
        <div class="zi"><span><</span> 搜索</div>
        <div class="zheng">
            <input type="text" placeholder="搜索商家/商品名称" v-model="zhi"><span class="c1" @click="add">搜索</span>
        </div>
        <div class="hang">
            <span>历史搜索</span>
        </div>
        <div class="hang2" v-for="(item,index) in list" :key="index">
            <div class="nei">{{item.name}}</div>
        </div>
    
    </div>
</body>

</html>
<script src="./vue-2.5.21.js"></script>
<script>
    var v=new Vue({
        el:'.box',
        data:{
            zhi:'',
            list:[]

        },
        methods:{
            add() {
                if(this.zhi){
                    var obj={id:this.list.length+1,name:this.zhi}
                    this.list.push(obj)
                    this.zhi=''
                }
            }
        }
    })
</script>